#ScsAlarmCond1 - detect event 01-20002 from application corresponding to LocalTserver (LinkDisconnected).
#To cause alarm - change link port
#Reaction - switchover

#ScsAlarmCond2 - detect event 00-05064 from application corresponding to LocalTserver (Application exited).
#To cause alarm - stop this application.
#Reaction - start this application

#ScsAlarmCond3 - detect event 00-04504 from application corresponding to Router (connection to  server lost)
#To cause alarm - switchover warm standby tservers
#Reaction - send e-mail. Verification is manual
def a():
  pass

def alarm_testing_1():

  cfgApp = LocalTserver.FindPrimaryCfgApp()
  tserverSection = cfgApp.options["TServer"] #should be there
  linkSectionName1= tserverSection ["link-1-name"] #should be there
  linkSectionName2 = None
  if tserverSection.has_key("link-2-name"):
    linkSectionName2= tserverSection ["link-2-name"] #should be there

  #preparation for switchover
  LocalTserver.Close() 
  # to produce alarm LinkDisconnected - change to reference to link
  ScsAlarmCond1.ProduceAlarm(["CfgLocalTserver.ChangeOption(\"TServer\", \"link-1-name\", \"NoSuchSection\", inBackupToo = 0)"], ["ScsAppLocalTserver.Switchover(fromScript = 0)"])
  cfgApp.ChangeOption("TServer", "link-1-name", linkSectionName1, inBackupToo = 0)  # return it back

def alarm_testing_2():
  #No preparation needed, LocalTserver.Close() will be executed in method Switchover
  ScsAlarmCond3.ProduceAlarm(["ScsAppLocalTserver.Switchover()"], ["Manual"])


def alarm_testing_3():
  #No preparation needed, LocalTserver.Close() will be executed in method Stop
  ScsAlarmCond2.ProduceAlarm(["ScsAppLocalTserver.Stop()"], ["ScsAppLocalTserver.Start(fromScript = 0)"])



